package com.audi.core.dao;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;
import java.util.Map;

import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Criterion;
import org.springframework.beans.factory.annotation.Autowired;

public interface SimpleDAO<T, PK extends Serializable> {

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#getSessionFactory()
	 */
	public abstract SessionFactory getSessionFactory();

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#setSessionFactory(org.hibernate.SessionFactory)
	 */
	@Autowired
	public abstract void setSessionFactory(final SessionFactory sessionFactory);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#getSession()
	 */
	public abstract Session getSession();

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#save(T)
	 */
	public abstract T save(final T entity);

	public abstract T update(T entity);

	public abstract T merge(T entity);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#delete(T)
	 */
	public abstract void delete(final T entity);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#delete(PK)
	 */
	public abstract void delete(final PK id);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#get(PK)
	 */
	public abstract T get(final PK id);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#get(java.util.Collection)
	 */
	public abstract List<T> get(final Collection<PK> ids);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#getAll()
	 */
	public abstract List<T> getAll();

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#getAll(java.lang.String, boolean)
	 */
	public abstract List<T> getAll(String orderByProperty, boolean isAsc);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#findBy(java.lang.String, java.lang.Object)
	 */
	public abstract List<T> findBy(final String propertyName, final Object value);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#findUniqueBy(java.lang.String, java.lang.Object)
	 */
	public abstract T findUniqueBy(final String propertyName, final Object value);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#find(java.lang.String, java.lang.Object)
	 */
	public abstract <X> List<X> find(final String hql, final Object... values);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#find(java.lang.String, java.util.Map)
	 */
	public abstract <X> List<X> find(final String hql,
			final Map<String, ?> values);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#findUnique(java.lang.String, java.lang.Object)
	 */
	public abstract <X> X findUnique(final String hql, final Object... values);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#findUnique(java.lang.String, java.util.Map)
	 */
	public abstract <X> X findUnique(final String hql,
			final Map<String, ?> values);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#batchExecute(java.lang.String, java.lang.Object)
	 */
	public abstract int batchExecute(final String hql, final Object... values);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#batchExecute(java.lang.String, java.util.Map)
	 */
	public abstract int batchExecute(final String hql,
			final Map<String, ?> values);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#createQuery(java.lang.String, java.lang.Object)
	 */
	public abstract Query createQuery(final String queryString,
			final Object... values);

	
	public Query createQuery(final String queryString);
	
	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#createQuery(java.lang.String, java.util.Map)
	 */
	public abstract Query createQuery(final String queryString,
			final Map<String, ?> values);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#find(org.hibernate.criterion.Criterion)
	 */
	public abstract List<T> find(final Criterion... criterions);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#findUnique(org.hibernate.criterion.Criterion)
	 */
	public abstract T findUnique(final Criterion... criterions);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#createCriteria(org.hibernate.criterion.Criterion)
	 */
	public abstract Criteria createCriteria(final Criterion... criterions);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#initProxyObject(java.lang.Object)
	 */
	public abstract void initProxyObject(Object proxy);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#flush()
	 */
	public abstract void flush();

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#distinct(org.hibernate.Query)
	 */
	public abstract Query distinct(Query query);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#distinct(org.hibernate.Criteria)
	 */
	public abstract Criteria distinct(Criteria criteria);

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#getIdName()
	 */
	public abstract String getIdName();

	/* (non-Javadoc)
	 * @see com.sitech.core.orm.hibernate.Sdd#isPropertyUnique(java.lang.String, java.lang.Object, java.lang.Object)
	 */
	public abstract boolean isPropertyUnique(final String propertyName,
			final Object newValue, final Object oldValue);

}